﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Trains.Models
{
    public class Station
    {
        public string Name { get; set; }

        public IList<Route> Routes { get; set; } = new List<Route>();

        public Station(string name)
        {
            this.Name = name;
        }

        public Station(string name, List<Route> routes)
        {
            this.Name = name;
            this.Routes = routes;
        }

        public void AddRoute(Route route)
        {
            this.Routes.Add(route);
        }

        public Route GetRouteOfStation(string toStationName)
        {
            return this.Routes.FirstOrDefault(f => f.To.Name == toStationName);
        }
    }
}
